/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * MainFrame.java
 *
 * Created on Jan 10, 2010, 2:59:04 AM
 */
package gui;

import engine.Unit;
import java.awt.Color;
import java.util.Calendar;
import java.util.GregorianCalendar;
import javax.swing.JColorChooser;

/**
 *
 * @author Johnny
 */
public class MainFrame extends javax.swing.JFrame {

    /** Creates new form MainFrame */
    public MainFrame() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        control = new gui.Control();
        mapPanel = new gui.MapPanel();
        tplControl = new javax.swing.JTabbedPane();
        plView = new javax.swing.JPanel();
        lbTime = new javax.swing.JLabel();
        spHour = new javax.swing.JSpinner();
        spMinute = new javax.swing.JSpinner();
        spSecond = new javax.swing.JSpinner();
        btNow = new javax.swing.JButton();
        btStartStop = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        ltUnit = new javax.swing.JList();
        plNodes = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        tfNodeName = new javax.swing.JTextField();
        tfNodeX = new javax.swing.JTextField();
        tfNodeY = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        btAddNode = new javax.swing.JButton();
        cbNodes = new javax.swing.JComboBox();
        btDeleteNode = new javax.swing.JButton();
        btNodeUpdate = new javax.swing.JButton();
        plEdges = new javax.swing.JPanel();
        jLabel5 = new javax.swing.JLabel();
        cbEdge = new javax.swing.JComboBox();
        jLabel6 = new javax.swing.JLabel();
        btEdgeColor = new javax.swing.JButton();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        btEdgeAdd = new javax.swing.JButton();
        btEdgeUpdate = new javax.swing.JButton();
        btEdgeDelete = new javax.swing.JButton();
        jSeparator1 = new javax.swing.JSeparator();
        jLabel9 = new javax.swing.JLabel();
        cbEdgeMnAdd = new javax.swing.JComboBox();
        btEdgeMnAdd = new javax.swing.JButton();
        cbEdgeMnRemove = new javax.swing.JComboBox();
        btEdgeMnRemove = new javax.swing.JButton();
        cbEdgeStart = new javax.swing.JComboBox();
        cbEdgeEnd = new javax.swing.JComboBox();
        plUnits = new javax.swing.JPanel();
        jLabel10 = new javax.swing.JLabel();
        cbUnit = new javax.swing.JComboBox();
        btUnitAdd = new javax.swing.JButton();
        btUnitUpdate = new javax.swing.JButton();
        btUnitDelete = new javax.swing.JButton();
        jSeparator2 = new javax.swing.JSeparator();
        jLabel11 = new javax.swing.JLabel();
        cbUnitCpAdd = new javax.swing.JComboBox();
        btUnitCpAdd = new javax.swing.JButton();
        cbUnitCpRemove = new javax.swing.JComboBox();
        btUnitCpRemove = new javax.swing.JButton();
        jLabel12 = new javax.swing.JLabel();
        tfUnitName = new javax.swing.JTextField();
        plInstances = new javax.swing.JPanel();
        jLabel13 = new javax.swing.JLabel();
        cbInstUnit = new javax.swing.JComboBox();
        jLabel14 = new javax.swing.JLabel();
        jSeparator3 = new javax.swing.JSeparator();
        cbInst = new javax.swing.JComboBox();
        btInstAdd = new javax.swing.JButton();
        btInstRemove = new javax.swing.JButton();
        jSeparator4 = new javax.swing.JSeparator();
        jLabel15 = new javax.swing.JLabel();
        btInstUpdate = new javax.swing.JButton();
        ttSched = new gui.TimeTable();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("TransView");
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowOpened(java.awt.event.WindowEvent evt) {
                formWindowOpened(evt);
            }
        });

        mapPanel.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        mapPanel.setPreferredSize(mapPanel.getDim());
        mapPanel.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                mapPanelMouseClicked(evt);
            }
        });

        javax.swing.GroupLayout mapPanelLayout = new javax.swing.GroupLayout(mapPanel);
        mapPanel.setLayout(mapPanelLayout);
        mapPanelLayout.setHorizontalGroup(
            mapPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 678, Short.MAX_VALUE)
        );
        mapPanelLayout.setVerticalGroup(
            mapPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 488, Short.MAX_VALUE)
        );

        tplControl.setMaximumSize(new java.awt.Dimension(200, 32767));
        tplControl.setMinimumSize(new java.awt.Dimension(200, 5));
        tplControl.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                tplControlStateChanged(evt);
            }
        });

        plView.setName("plView"); // NOI18N

        lbTime.setText("Time:");

        spHour.setModel(new javax.swing.SpinnerNumberModel(0, 0, 23, 1));

        spMinute.setModel(new javax.swing.SpinnerNumberModel(0, 0, 59, 1));

        spSecond.setModel(new javax.swing.SpinnerNumberModel(0, 0, 59, 1));

        btNow.setText("Now");
        btNow.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btNowActionPerformed(evt);
            }
        });

        btStartStop.setText("Start");
        btStartStop.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btStartStopActionPerformed(evt);
            }
        });

        ltUnit.setModel(new javax.swing.AbstractListModel() {
            String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" };
            public int getSize() { return strings.length; }
            public Object getElementAt(int i) { return strings[i]; }
        });
        jScrollPane1.setViewportView(ltUnit);

        javax.swing.GroupLayout plViewLayout = new javax.swing.GroupLayout(plView);
        plView.setLayout(plViewLayout);
        plViewLayout.setHorizontalGroup(
            plViewLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(plViewLayout.createSequentialGroup()
                .addGroup(plViewLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(plViewLayout.createSequentialGroup()
                        .addGroup(plViewLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(plViewLayout.createSequentialGroup()
                                .addGap(14, 14, 14)
                                .addComponent(lbTime)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(spHour, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(plViewLayout.createSequentialGroup()
                                .addContainerGap()
                                .addComponent(btNow, javax.swing.GroupLayout.PREFERRED_SIZE, 77, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(plViewLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addGroup(plViewLayout.createSequentialGroup()
                                .addComponent(spMinute, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(spSecond, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(btStartStop, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                    .addGroup(plViewLayout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 186, Short.MAX_VALUE)))
                .addContainerGap())
        );
        plViewLayout.setVerticalGroup(
            plViewLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(plViewLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(plViewLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lbTime)
                    .addComponent(spHour, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(spMinute, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(spSecond, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(plViewLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btNow)
                    .addComponent(btStartStop))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 385, Short.MAX_VALUE)
                .addContainerGap())
        );

        tplControl.addTab("View", plView);

        plNodes.setName("plNodes"); // NOI18N

        jLabel1.setText("Name");

        tfNodeName.setText("name");

        tfNodeX.setText("0.0");
        tfNodeX.setName("X"); // NOI18N

        tfNodeY.setText("0.0");
        tfNodeY.setName("Y"); // NOI18N

        jLabel2.setText("X%");

        jLabel3.setText("Y%");

        jLabel4.setText("Select node:");

        btAddNode.setText("Add");
        btAddNode.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btAddNodeActionPerformed(evt);
            }
        });

        cbNodes.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        cbNodes.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                cbNodesItemStateChanged(evt);
            }
        });

        btDeleteNode.setText("Delete");
        btDeleteNode.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btDeleteNodeActionPerformed(evt);
            }
        });

        btNodeUpdate.setText("Update");
        btNodeUpdate.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btNodeUpdateActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout plNodesLayout = new javax.swing.GroupLayout(plNodes);
        plNodes.setLayout(plNodesLayout);
        plNodesLayout.setHorizontalGroup(
            plNodesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(plNodesLayout.createSequentialGroup()
                .addGroup(plNodesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(plNodesLayout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(plNodesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel4))
                        .addGap(9, 9, 9)
                        .addGroup(plNodesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(cbNodes, 0, 117, Short.MAX_VALUE)
                            .addComponent(tfNodeY, javax.swing.GroupLayout.DEFAULT_SIZE, 117, Short.MAX_VALUE)
                            .addComponent(tfNodeX, javax.swing.GroupLayout.DEFAULT_SIZE, 117, Short.MAX_VALUE)
                            .addComponent(tfNodeName, javax.swing.GroupLayout.DEFAULT_SIZE, 117, Short.MAX_VALUE)))
                    .addGroup(plNodesLayout.createSequentialGroup()
                        .addComponent(btAddNode)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btNodeUpdate)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btDeleteNode)))
                .addContainerGap())
        );
        plNodesLayout.setVerticalGroup(
            plNodesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(plNodesLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(plNodesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(cbNodes, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(plNodesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel1)
                    .addComponent(tfNodeName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGroup(plNodesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(plNodesLayout.createSequentialGroup()
                        .addGap(12, 12, 12)
                        .addComponent(jLabel2))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, plNodesLayout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(tfNodeX, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(plNodesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(tfNodeY, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel3))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(plNodesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btAddNode)
                    .addComponent(btNodeUpdate)
                    .addComponent(btDeleteNode))
                .addContainerGap(319, Short.MAX_VALUE))
        );

        tplControl.addTab("Nodes", plNodes);

        jLabel5.setText("Select edge:");

        cbEdge.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        cbEdge.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                cbEdgeItemStateChanged(evt);
            }
        });

        jLabel6.setText("Color:");

        btEdgeColor.setFont(new java.awt.Font("Tahoma", 1, 11));
        btEdgeColor.setText("Choose");
        btEdgeColor.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btEdgeColorActionPerformed(evt);
            }
        });

        jLabel7.setText("Start node:");

        jLabel8.setText("End node:");

        btEdgeAdd.setText("Add");
        btEdgeAdd.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btEdgeAddActionPerformed(evt);
            }
        });

        btEdgeUpdate.setText("Update");
        btEdgeUpdate.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btEdgeUpdateActionPerformed(evt);
            }
        });

        btEdgeDelete.setText("Delete");
        btEdgeDelete.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btEdgeDeleteActionPerformed(evt);
            }
        });

        jLabel9.setText("Middle nodes");

        cbEdgeMnAdd.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));

        btEdgeMnAdd.setText("Add");
        btEdgeMnAdd.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btEdgeMnAddActionPerformed(evt);
            }
        });

        cbEdgeMnRemove.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));

        btEdgeMnRemove.setText("Remove");
        btEdgeMnRemove.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btEdgeMnRemoveActionPerformed(evt);
            }
        });

        cbEdgeStart.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));

        cbEdgeEnd.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));

        javax.swing.GroupLayout plEdgesLayout = new javax.swing.GroupLayout(plEdges);
        plEdges.setLayout(plEdgesLayout);
        plEdgesLayout.setHorizontalGroup(
            plEdgesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(plEdgesLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(plEdgesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(plEdgesLayout.createSequentialGroup()
                        .addGroup(plEdgesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(plEdgesLayout.createSequentialGroup()
                                .addGroup(plEdgesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel5)
                                    .addComponent(jLabel6))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(plEdgesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(btEdgeColor)
                                    .addComponent(cbEdge, 0, 129, Short.MAX_VALUE)))
                            .addGroup(plEdgesLayout.createSequentialGroup()
                                .addGroup(plEdgesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel7)
                                    .addComponent(jLabel8))
                                .addGap(10, 10, 10)
                                .addGroup(plEdgesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(cbEdgeEnd, 0, 128, Short.MAX_VALUE)
                                    .addComponent(cbEdgeStart, javax.swing.GroupLayout.Alignment.LEADING, 0, 128, Short.MAX_VALUE)))
                            .addGroup(plEdgesLayout.createSequentialGroup()
                                .addComponent(btEdgeAdd)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(btEdgeUpdate)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(btEdgeDelete))
                            .addComponent(jSeparator1, javax.swing.GroupLayout.DEFAULT_SIZE, 193, Short.MAX_VALUE)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, plEdgesLayout.createSequentialGroup()
                                .addGroup(plEdgesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(cbEdgeMnAdd, 0, 116, Short.MAX_VALUE)
                                    .addComponent(cbEdgeMnRemove, 0, 116, Short.MAX_VALUE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(plEdgesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                    .addComponent(btEdgeMnAdd, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(btEdgeMnRemove, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
                        .addContainerGap())
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, plEdgesLayout.createSequentialGroup()
                        .addComponent(jLabel9)
                        .addGap(73, 73, 73))))
        );
        plEdgesLayout.setVerticalGroup(
            plEdgesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(plEdgesLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(plEdgesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel5)
                    .addComponent(cbEdge, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(plEdgesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel6)
                    .addComponent(btEdgeColor))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(plEdgesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel7)
                    .addComponent(cbEdgeStart, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(plEdgesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel8)
                    .addComponent(cbEdgeEnd, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(plEdgesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btEdgeAdd)
                    .addComponent(btEdgeUpdate)
                    .addComponent(btEdgeDelete))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(4, 4, 4)
                .addComponent(jLabel9)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(plEdgesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btEdgeMnAdd)
                    .addComponent(cbEdgeMnAdd, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(plEdgesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btEdgeMnRemove)
                    .addComponent(cbEdgeMnRemove, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(224, Short.MAX_VALUE))
        );

        tplControl.addTab("Edges", plEdges);

        jLabel10.setText("Select unit:");

        cbUnit.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        cbUnit.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                cbUnitItemStateChanged(evt);
            }
        });

        btUnitAdd.setText("Add");
        btUnitAdd.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btUnitAddActionPerformed(evt);
            }
        });

        btUnitUpdate.setText("Update");
        btUnitUpdate.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btUnitUpdateActionPerformed(evt);
            }
        });

        btUnitDelete.setText("Delete");
        btUnitDelete.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btUnitDeleteActionPerformed(evt);
            }
        });

        jLabel11.setText("Course points");

        cbUnitCpAdd.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));

        btUnitCpAdd.setText("Add");
        btUnitCpAdd.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btUnitCpAddActionPerformed(evt);
            }
        });

        cbUnitCpRemove.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));

        btUnitCpRemove.setText("Remove");
        btUnitCpRemove.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btUnitCpRemoveActionPerformed(evt);
            }
        });

        jLabel12.setText("Name:");

        tfUnitName.setText("name");

        javax.swing.GroupLayout plUnitsLayout = new javax.swing.GroupLayout(plUnits);
        plUnits.setLayout(plUnitsLayout);
        plUnitsLayout.setHorizontalGroup(
            plUnitsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(plUnitsLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(plUnitsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(plUnitsLayout.createSequentialGroup()
                        .addGroup(plUnitsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel12)
                            .addComponent(jLabel10))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(plUnitsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(tfUnitName, javax.swing.GroupLayout.DEFAULT_SIZE, 135, Short.MAX_VALUE)
                            .addComponent(cbUnit, 0, 135, Short.MAX_VALUE)))
                    .addGroup(plUnitsLayout.createSequentialGroup()
                        .addComponent(btUnitAdd)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btUnitUpdate)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btUnitDelete))
                    .addComponent(jSeparator2, javax.swing.GroupLayout.DEFAULT_SIZE, 193, Short.MAX_VALUE)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, plUnitsLayout.createSequentialGroup()
                        .addGroup(plUnitsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(cbUnitCpAdd, 0, 116, Short.MAX_VALUE)
                            .addComponent(cbUnitCpRemove, 0, 116, Short.MAX_VALUE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(plUnitsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addComponent(btUnitCpAdd, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(btUnitCpRemove)))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, plUnitsLayout.createSequentialGroup()
                        .addComponent(jLabel11)
                        .addGap(63, 63, 63)))
                .addGap(3, 3, 3))
        );
        plUnitsLayout.setVerticalGroup(
            plUnitsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(plUnitsLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(plUnitsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel10)
                    .addComponent(cbUnit, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(11, 11, 11)
                .addGroup(plUnitsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel12)
                    .addComponent(tfUnitName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(plUnitsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btUnitAdd)
                    .addComponent(btUnitUpdate)
                    .addComponent(btUnitDelete))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(4, 4, 4)
                .addComponent(jLabel11)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(plUnitsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btUnitCpAdd)
                    .addComponent(cbUnitCpAdd, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(plUnitsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btUnitCpRemove)
                    .addComponent(cbUnitCpRemove, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(279, Short.MAX_VALUE))
        );

        tplControl.addTab("Units", plUnits);

        jLabel13.setText("Unit:");

        cbInstUnit.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        cbInstUnit.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                cbInstUnitItemStateChanged(evt);
            }
        });

        jLabel14.setText("Instance:");

        cbInst.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        cbInst.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                cbInstItemStateChanged(evt);
            }
        });

        btInstAdd.setText("Add");
        btInstAdd.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btInstAddActionPerformed(evt);
            }
        });

        btInstRemove.setText("Remove");
        btInstRemove.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btInstRemoveActionPerformed(evt);
            }
        });

        jLabel15.setText("Schedule");

        btInstUpdate.setText("Update");
        btInstUpdate.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btInstUpdateActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout ttSchedLayout = new javax.swing.GroupLayout(ttSched);
        ttSched.setLayout(ttSchedLayout);
        ttSchedLayout.setHorizontalGroup(
            ttSchedLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 186, Short.MAX_VALUE)
        );
        ttSchedLayout.setVerticalGroup(
            ttSchedLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 293, Short.MAX_VALUE)
        );

        javax.swing.GroupLayout plInstancesLayout = new javax.swing.GroupLayout(plInstances);
        plInstances.setLayout(plInstancesLayout);
        plInstancesLayout.setHorizontalGroup(
            plInstancesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(plInstancesLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(plInstancesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(plInstancesLayout.createSequentialGroup()
                        .addComponent(ttSched, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addContainerGap())
                    .addGroup(plInstancesLayout.createSequentialGroup()
                        .addComponent(jSeparator4, javax.swing.GroupLayout.DEFAULT_SIZE, 186, Short.MAX_VALUE)
                        .addContainerGap())
                    .addGroup(plInstancesLayout.createSequentialGroup()
                        .addGroup(plInstancesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jSeparator3, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 186, Short.MAX_VALUE)
                            .addGroup(plInstancesLayout.createSequentialGroup()
                                .addComponent(jLabel13)
                                .addGap(18, 18, 18)
                                .addComponent(cbInstUnit, 0, 145, Short.MAX_VALUE))
                            .addGroup(plInstancesLayout.createSequentialGroup()
                                .addComponent(jLabel14)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(cbInst, 0, 130, Short.MAX_VALUE)))
                        .addContainerGap())
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, plInstancesLayout.createSequentialGroup()
                        .addComponent(btInstAdd)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btInstRemove)
                        .addGap(32, 32, 32))
                    .addGroup(plInstancesLayout.createSequentialGroup()
                        .addComponent(jLabel15)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 76, Short.MAX_VALUE)
                        .addComponent(btInstUpdate)
                        .addContainerGap())))
        );
        plInstancesLayout.setVerticalGroup(
            plInstancesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(plInstancesLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(plInstancesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel13)
                    .addComponent(cbInstUnit, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jSeparator3, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(plInstancesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel14)
                    .addComponent(cbInst, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(plInstancesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btInstRemove)
                    .addComponent(btInstAdd))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jSeparator4, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(plInstancesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel15)
                    .addComponent(btInstUpdate))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(ttSched, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );

        tplControl.addTab("Instances", plInstances);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(mapPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(tplControl, javax.swing.GroupLayout.PREFERRED_SIZE, 211, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(tplControl, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(mapPanel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addGap(47, 47, 47))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btNowActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btNowActionPerformed
        Calendar ca = new GregorianCalendar();
        spHour.setValue(ca.get(Calendar.HOUR_OF_DAY));
        spMinute.setValue(ca.get(Calendar.MINUTE));
        spSecond.setValue(ca.get(Calendar.SECOND));
    }//GEN-LAST:event_btNowActionPerformed

    private void formWindowOpened(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowOpened
        control.setMapPanel(mapPanel).setFrame(this);
        control.viewPanelSelected();
    }//GEN-LAST:event_formWindowOpened

    private void btStartStopActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btStartStopActionPerformed
        if (btStartStop.getText().equals("Start")) {
            Object objects[] = ltUnit.getSelectedValues();
            Unit units[] = new Unit[objects.length];
            for (int i = 0; i < objects.length; i++) {
                units[i] = (Unit) objects[i];
            }
            control.viewMap(units, (Integer) spHour.getValue(),
                    (Integer) spMinute.getValue(),
                    (Integer) spSecond.getValue());
        } else {
            control.stopTimer();
        }
    }//GEN-LAST:event_btStartStopActionPerformed

    private void tplControlStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_tplControlStateChanged
        if (control.isInitialized()) {
            if (tplControl.getSelectedComponent() == plView) {
                control.viewPanelSelected();
            } else if (tplControl.getSelectedComponent() == plNodes) {
                control.nodesPanelSelected();
            } else if (tplControl.getSelectedComponent() == plEdges) {
                control.edgesPanelSelected();
            } else if (tplControl.getSelectedComponent() == plUnits) {
                control.unitsPanelSelected();
            } else if (tplControl.getSelectedComponent() == plInstances) {
                control.instPanelSelected();
            }
        }
    }//GEN-LAST:event_tplControlStateChanged

    private void mapPanelMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_mapPanelMouseClicked
        control.setMousePos(evt.getX(), evt.getY());
    }//GEN-LAST:event_mapPanelMouseClicked

    private void btAddNodeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btAddNodeActionPerformed
        float x = Float.parseFloat(tfNodeX.getText());
        float y = Float.parseFloat(tfNodeY.getText());
        control.getEngine().addNode(x, y, tfNodeName.getText());
        control.nodesPanelSelected();
    }//GEN-LAST:event_btAddNodeActionPerformed

    private void cbNodesItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cbNodesItemStateChanged
        control.fillNodeData();
    }//GEN-LAST:event_cbNodesItemStateChanged

    private void btDeleteNodeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btDeleteNodeActionPerformed
        control.deleteNode();
    }//GEN-LAST:event_btDeleteNodeActionPerformed

    private void btNodeUpdateActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btNodeUpdateActionPerformed
        control.updateNode();
    }//GEN-LAST:event_btNodeUpdateActionPerformed

    private void btEdgeColorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btEdgeColorActionPerformed
        Color cc = JColorChooser.showDialog(this, "Choose a color", btEdgeColor.getForeground());
        if (cc != null) {
            btEdgeColor.setForeground(cc);
            btEdgeColor.setBackground(cc);
        }
    }//GEN-LAST:event_btEdgeColorActionPerformed

    private void btEdgeAddActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btEdgeAddActionPerformed
        control.addEdge();
    }//GEN-LAST:event_btEdgeAddActionPerformed

    private void btEdgeUpdateActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btEdgeUpdateActionPerformed
        control.updateEdge();
    }//GEN-LAST:event_btEdgeUpdateActionPerformed

    private void cbEdgeItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cbEdgeItemStateChanged
        control.fillEdgeData();
    }//GEN-LAST:event_cbEdgeItemStateChanged

    private void btEdgeDeleteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btEdgeDeleteActionPerformed
        control.deleteEdge();
    }//GEN-LAST:event_btEdgeDeleteActionPerformed

    private void btEdgeMnAddActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btEdgeMnAddActionPerformed
        control.addEdgeMiddleNode();
    }//GEN-LAST:event_btEdgeMnAddActionPerformed

    private void btEdgeMnRemoveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btEdgeMnRemoveActionPerformed
        control.removeEdgeMiddleNode();
    }//GEN-LAST:event_btEdgeMnRemoveActionPerformed

    private void cbUnitItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cbUnitItemStateChanged
        control.fillUnitData();
    }//GEN-LAST:event_cbUnitItemStateChanged

    private void btUnitAddActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btUnitAddActionPerformed
        control.addUnit();
    }//GEN-LAST:event_btUnitAddActionPerformed

    private void btUnitUpdateActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btUnitUpdateActionPerformed
        control.updateUnit();
    }//GEN-LAST:event_btUnitUpdateActionPerformed

    private void btUnitDeleteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btUnitDeleteActionPerformed
        control.deleteUnit();
    }//GEN-LAST:event_btUnitDeleteActionPerformed

    private void btUnitCpAddActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btUnitCpAddActionPerformed
        control.addUnitCourse();
    }//GEN-LAST:event_btUnitCpAddActionPerformed

    private void btUnitCpRemoveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btUnitCpRemoveActionPerformed
        control.removeUnitCourse();
    }//GEN-LAST:event_btUnitCpRemoveActionPerformed

    private void cbInstUnitItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cbInstUnitItemStateChanged
        control.fillInstData();
    }//GEN-LAST:event_cbInstUnitItemStateChanged

    private void cbInstItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cbInstItemStateChanged
        control.fillSchedData();
    }//GEN-LAST:event_cbInstItemStateChanged

    private void btInstAddActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btInstAddActionPerformed
        control.addInstance();
    }//GEN-LAST:event_btInstAddActionPerformed

    private void btInstRemoveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btInstRemoveActionPerformed
        control.removeInstance();
    }//GEN-LAST:event_btInstRemoveActionPerformed

    private void btInstUpdateActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btInstUpdateActionPerformed
        control.updateInstance();
    }//GEN-LAST:event_btInstUpdateActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new MainFrame().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    javax.swing.JButton btAddNode;
    javax.swing.JButton btDeleteNode;
    javax.swing.JButton btEdgeAdd;
    javax.swing.JButton btEdgeColor;
    javax.swing.JButton btEdgeDelete;
    javax.swing.JButton btEdgeMnAdd;
    javax.swing.JButton btEdgeMnRemove;
    javax.swing.JButton btEdgeUpdate;
    javax.swing.JButton btInstAdd;
    javax.swing.JButton btInstRemove;
    javax.swing.JButton btInstUpdate;
    javax.swing.JButton btNodeUpdate;
    javax.swing.JButton btNow;
    javax.swing.JButton btStartStop;
    javax.swing.JButton btUnitAdd;
    javax.swing.JButton btUnitCpAdd;
    javax.swing.JButton btUnitCpRemove;
    javax.swing.JButton btUnitDelete;
    javax.swing.JButton btUnitUpdate;
    javax.swing.JComboBox cbEdge;
    javax.swing.JComboBox cbEdgeEnd;
    javax.swing.JComboBox cbEdgeMnAdd;
    javax.swing.JComboBox cbEdgeMnRemove;
    javax.swing.JComboBox cbEdgeStart;
    javax.swing.JComboBox cbInst;
    javax.swing.JComboBox cbInstUnit;
    javax.swing.JComboBox cbNodes;
    javax.swing.JComboBox cbUnit;
    javax.swing.JComboBox cbUnitCpAdd;
    javax.swing.JComboBox cbUnitCpRemove;
    gui.Control control;
    javax.swing.JLabel jLabel1;
    javax.swing.JLabel jLabel10;
    javax.swing.JLabel jLabel11;
    javax.swing.JLabel jLabel12;
    javax.swing.JLabel jLabel13;
    javax.swing.JLabel jLabel14;
    javax.swing.JLabel jLabel15;
    javax.swing.JLabel jLabel2;
    javax.swing.JLabel jLabel3;
    javax.swing.JLabel jLabel4;
    javax.swing.JLabel jLabel5;
    javax.swing.JLabel jLabel6;
    javax.swing.JLabel jLabel7;
    javax.swing.JLabel jLabel8;
    javax.swing.JLabel jLabel9;
    javax.swing.JScrollPane jScrollPane1;
    javax.swing.JSeparator jSeparator1;
    javax.swing.JSeparator jSeparator2;
    javax.swing.JSeparator jSeparator3;
    javax.swing.JSeparator jSeparator4;
    javax.swing.JLabel lbTime;
    javax.swing.JList ltUnit;
    gui.MapPanel mapPanel;
    javax.swing.JPanel plEdges;
    javax.swing.JPanel plInstances;
    javax.swing.JPanel plNodes;
    javax.swing.JPanel plUnits;
    javax.swing.JPanel plView;
    javax.swing.JSpinner spHour;
    javax.swing.JSpinner spMinute;
    javax.swing.JSpinner spSecond;
    javax.swing.JTextField tfNodeName;
    javax.swing.JTextField tfNodeX;
    javax.swing.JTextField tfNodeY;
    javax.swing.JTextField tfUnitName;
    javax.swing.JTabbedPane tplControl;
    gui.TimeTable ttSched;
    // End of variables declaration//GEN-END:variables
}
